package com.daafan.minilib.data;

import java.util.List;

import android.content.Context;
import net.tsz.afinal.FinalDb;
import net.tsz.afinal.annotation.sqlite.Id;

public class BookData {
	@Id
	private int		id;
	public String	author		= "";
	public String	bookid		= "";
	public String	bookname	= "";
	public String	imgurl		= "";
	public String	pub			= "";
	public String	pubtime;
	public String	updatetime;
	public String	pdfurl		= "";
	public String	pdfPath		= "";

	public boolean	isDownloading;
	public boolean	isFinish;

	/** 文件总大小 */
	public long		countBit	= 1;
	/** 当前下载进度 */
	public long		current;

	public void update(Context context) {
		FinalDb db = FinalDb.create(context);

		String where = "bookid=\"" + bookid + "\"";
		List<BookData> list = db.findAllByWhere(BookData.class, where);
		db.deleteByWhere(BookData.class, where);
		db.save(this);
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getBookid() {
		return bookid;
	}

	public void setBookid(String bookid) {
		this.bookid = bookid;
	}

	public String getBookname() {
		return bookname;
	}

	public void setBookname(String bookname) {
		this.bookname = bookname;
	}

	public String getImgurl() {
		return imgurl;
	}

	public void setImgurl(String imgurl) {
		this.imgurl = imgurl;
	}

	public String getPub() {
		return pub;
	}

	public void setPub(String pub) {
		this.pub = pub;
	}

	public String getPubtime() {
		return pubtime;
	}

	public void setPubtime(String pubtime) {
		this.pubtime = pubtime;
	}

	public String getUpdatetime() {
		return updatetime;
	}

	public void setUpdatetime(String updatetime) {
		this.updatetime = updatetime;
	}

	public long getCountSize() {
		return countBit;
	}

	public void setCountSize(long countSize) {
		this.countBit = countSize;
	}

	public long getCurrent() {
		return current;
	}

	public void setCurrent(long current) {
		this.current = current;
	}

	public String getPdfurl() {
		return pdfurl;
	}

	public void setPdfurl(String pdfurl) {
		this.pdfurl = pdfurl;
	}

	public String getPdfPath() {
		return pdfPath;
	}

	public void setPdfPath(String pdfPath) {
		this.pdfPath = pdfPath;
	}

	public long getCountBit() {
		return countBit;
	}

	public void setCountBit(long countBit) {
		this.countBit = countBit;
	}

	public boolean isFinish() {
		return isFinish;
	}

	public void setFinish(boolean isFinish) {
		this.isFinish = isFinish;
	}

}
